﻿<#include "/common/easyui-css.html">
<#include "/common/easyui-js.html">
<#include "/common/loading.html">
<script type="text/javascript" src="/lib/layer/2.4/layer.js"></script>

<body class="easyui-layout">
<div data-options="region:'center',border:false" style="padding:2px;height: auto">
    <table id="column_table" class="easyui-datagrid" title="" style="width:100%;height:100%;padding-bottom: 2px;"
           data-options="rownumbers:true,
                      pagination:true,
                      singleSelect:true,
                      url:'/config-column-list/1/20',
                      method:'get',
                      toolbar:'#tb',
                      nowrap:false,
                      loadMsg : '数据加载中',
                      fitColumns : true,
                      showFooter: true" >
        <thead>
            <tr>
                <th data-options="field:'tableName', width:20" >表格名称</th>
                <th data-options="field:'className', width:30" >实体名称</th>
                <th data-options="field:'allName', width:50" >所有列</th>
                <th data-options="field:'freezeName', width:50" >冻结列</th>
                <th data-options="field:'hiddenName', width:50" >隐藏列</th>

            </tr>
        </thead>
    </table>
</div>

<!-- 搜索框 -->
<div id="tb" style="padding:5px;height:auto">
	<div>
        模板名称1:<input class="easyui-textbox" id="to" style="width:120px" >
		<a href="#" class="easyui-linkbutton" iconCls="icon-search" id="searchByParameter">搜索</a>
	</div>
    <div style="margin:5px 0;"></div>
    <#include "/common/button.html">
</div>

<!-- 按钮操作 -->
<script type="text/javascript">
    //新增
    $("#add").click(function () {
        var url = '/column-add/-1';
        var index = layer.open({
            title:'新增设备信息',
            type: 2,
            fixed: false, //不固定
            maxmin: false,
            area: ['700px', '450px'],
            content: url
        });
        // layer.full(index);
    })
    //编辑
    $("#edit").click(function () {
        var row = $('#column_table').datagrid('getSelected');
        if (row){
            var url = '/column-add/'+row.id;
            var index = layer.open({
                title:'新增设备信息',
                type: 2,
                fixed: false, //不固定
                maxmin: false,
                area: ['700px', '450px'],
                content: url
            });
        } else {
            layer.msg('请选择需要编辑的表格', {icon: 2});
        }

    })

    //删除
    $("#delete").click(function () {
        var row = $('#column_table').datagrid('getSelected');
        if(row){
            layer.confirm('确定删除此设备？', {
                btn: ['删除','取消'] //按钮
            }, function(){
                $.ajax({
                    url : '/column-save/'+row.id,
                    data : {deleteFlag:'Y',tm : new Date().getTime()},
                    async : false,
                    success : function(){
                        $('#column_table').datagrid('reload');
                    }
                });
                layer.closeAll('dialog');
            }, function(){

            });
        }else{
            layer.msg('请选择需要删除的表格', {icon: 2});
        }
    })

    //设置
    $('#set').click(function () {
        var row = $('#column_table').datagrid('getSelected');
        if(row){
            var url = '/column-set/'+row.id;
            var index = layer.open({
                title:'表格信息',
                type: 2,
                fixed: false, //不固定
                maxmin: false,
                area: ['700px', '450px'],
                content: url
            });
            layer.full(index)
        }else{
            layer.msg('请选择需要设置的表格', {icon: 2});
        }
    });
</script>
<!-- 分页 -->
<script type="text/javascript">
	$(function(){
		var p = $('#column_table').datagrid().datagrid('getPager');
		p.pagination({
			pageSize: 20, //每页显示的记录条数，默认为10
			pageList: [20, 40, 60], //可以设置每页记录条数的列表
			onSelectPage: function (pageNumber, pageSize) {
			    if(pageNumber==0){
			        pageNumber = 1;
                }
				var handler = '/config-column-list/'+pageNumber+"/"+pageSize;
				$('#column_table').datagrid('options').url = handler;
				$('#column_table').datagrid('reload');
			}
		});
	})
</script>
